#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int singleNumber(vector<int>& nums)
    {
        int ret = 0;
        for (int i = 0; i < 32; i++)
        {
            int cur = 0;
            for (auto ch : nums)
                if (((ch >> i) & 1) == 1)
                    cur++;
            cur %= 3;
            if (cur == 1)
                ret |= (1 << i);
        }
        return ret;
    }
};